home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 5_5.lha / 5_5 / 5_5c3_W.c < prev    next >
Text File  |  1993-08-08  |  1KB  |  57 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / initialize for the WE32100
  6. / (nothing to do)
  7. oid setup()
  8.  
  9.  
  10.  
  11. / finish things up
  12. oid finishup(stackalloc &stacktop)
  13.  
  14.    cout << "\tMOVW ";
  15.    stacktop.print(cout) << ", result\n";
  16.  
  17.  
  18. / print out a binary operator followed by the
  19. / source and destination
  20. tatic void binop(const tree *head,
  21.    stackalloc &curloc, const intalloc *cursp)
  22.  
  23.    assemblyprint(head->left, curloc, cursp);
  24.    stackalloc newloc(cursp);
  25.    assemblyprint(head->right, newloc, cursp);
  26.  
  27.    switch (head->type)
  28. {
  29. case PLUS:  cout << "\tADDW2 "; break;
  30. case MUL:   cout << "\tMULW2 "; break;
  31. case DIV:   cout << "\tDIVW2 "; break;
  32. case MINUS: cout << "\tSUBW2 "; break;
  33. }
  34.  
  35.    newloc.print(cout) << ", ";
  36.    curloc.print(cout) << "\n";
  37.  
  38.  
  39. / print out a negate operator followed
  40. / by the destination
  41. tatic void negop(const tree *head,
  42.    stackalloc &curloc, const intalloc *cursp)
  43.  
  44.    stackalloc newloc(cursp);
  45.    assemblyprint(head->left, newloc, cursp);
  46.    cout << "\tMNEGW2 ";
  47.    newloc.print(cout) << ", ";
  48.    curloc.print(cout) << "\n";
  49.  
  50.  
  51. / store a number node at the current location
  52. tatic void svnumber(tree* head, stackalloc &curloc)
  53.  
  54.    cout << "\tMOVW &" << head->value << ", ";
  55.    curloc.print(cout) << "\n";
  56.  
  57.